package com.sky.controller.admin.statistics;

import com.sky.dto.PopularBooksQueryDTO;
import com.sky.result.Result;
import com.sky.service.PopularBooksStatisticsService;
import com.sky.vo.PopularBooksVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin")
@Api(tags = "热门图书统计接口")
@Slf4j
public class PopularBooksStatisticsController {

    @Autowired
    private PopularBooksStatisticsService popularBooksStatisticsService;

    /**
     * 获取热门图书借阅排行数据
     * @param queryDTO 查询参数
     * @return 热门图书数据
     */
    @GetMapping("/api/statistics/popular-books")
    @ApiOperation("获取热门图书借阅排行")
    public Result<PopularBooksVO> getPopularBooks(@Validated PopularBooksQueryDTO queryDTO) {
        log.info("获取热门图书借阅排行数据：{}", queryDTO);
        PopularBooksVO popularBooksVO = popularBooksStatisticsService.getPopularBooks(queryDTO);
        return Result.success(popularBooksVO);
    }
} 